package com.wtwd.campus.dao;

import com.wtwd.campus.entity.DeviceWhiteCall;
import com.wtwd.campus.entity.DeviceWhiteList;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.ArrayList;
import java.util.List;

/**
 * @author ljiong
 * @date 2021/06/29
 * @description
 */
@Mapper
public interface WhiteListMapper {

    List<DeviceWhiteList> getWhiteListByDeviceId(@Param("deviceId") Integer deviceId, @Param("type") Integer type);

    DeviceWhiteList getDeviceWhiteInfoById(@Param("id") Integer id);

    Integer updateWhiteList(@Param("deviceWhiteList") DeviceWhiteList deviceWhiteList);

    Integer bathAddWhiteCall(@Param("list") List<DeviceWhiteCall> batchAddList);

    Integer bathUpdateWhiteCall(@Param("list") ArrayList<DeviceWhiteCall> batchUpdateList);

    Integer delWhiteCall(@Param("deviceId") Integer deviceId, @Param("sequence") Integer sequence);

    Integer updateWhiteCallStatus(@Param("deviceId") Integer deviceId, @Param("sequence") Integer sequence, @Param("starts") int starts);

    Integer bathUpdateWhiteCallStatus(@Param("deviceId") Integer deviceId, @Param("sequenceList") List<Integer> sequenceList, @Param("start") int start);

    /**
     * 添加白名单
     *
     * @param deviceWhiteCall
     * @return
     */
    int addDeviceWhiteCall(DeviceWhiteCall deviceWhiteCall);

    /**
     * 更新白名单状态
     *
     * @param deviceId
     * @param sequence
     * @param status
     * @param commandNumber
     * @return
     */
    int updateDeviceWhiteCallStatus(@Param("deviceId") Integer deviceId, @Param("sequence") Integer sequence,
                                    @Param("status") Integer status, @Param("commandNumber") String commandNumber);

    List<DeviceWhiteList> getWhiteListByDeviceIdAndStarts(@Param("deviceId") Integer deviceId, @Param("start") int start);

    Integer updateWhiteListStarts(@Param("IdList") ArrayList<Integer> IdList, @Param("status") int status);


    int delDeviceWhiteList(@Param("deviceId") Integer deviceId, @Param("list") List<Integer> list);

    int addSomeWhiteList(@Param("list") List<DeviceWhiteList> list);

    /**
     * 根据设备id和序列号查找设备白名单
     *
     * @param deviceId
     * @param sequence
     * @return
     */
    DeviceWhiteList getDeviceWhiteListByDeviceIdAndSequence(@Param("deviceId") Integer deviceId, @Param("sequence") Integer sequence);

    /**
     * 更新白名单数据
     *
     * @param deviceId
     * @param sequence
     * @param name
     * @param phone
     * @param commandNumber
     * @param status
     * @return
     */
    int updateDeviceWhiteCall(@Param("deviceId") Integer deviceId, @Param("sequence") Integer sequence, @Param("name") String name,
                              @Param("phone") String phone, @Param("commandNumber") String commandNumber, @Param("status") Integer status);


    /**
     * 查找一个学生的亲情号码
     */
    List<DeviceWhiteList> getAffectionNumberByStuId(Integer stuId);

    /**
     * 修改一条亲情号码
     */
    Integer modifyAffectionNumber(@Param("id") Integer id, @Param("status") Integer status);

    /**
     * 根据id查找一条白名单记录
     */
    DeviceWhiteList getDeviceWhiteListById(Integer id);

    /**
     * 添加一笔白名单
     */
    Integer addDeviceWhiteList(@Param("data") DeviceWhiteCall deviceWhiteCall);

    /**
     * 根据微信用户id查询微信用户 的手机号码
     */
    String getNumberByWXUserId(Integer userId);

    /**
     * 根绝设备id查找一个学生的亲情号码
     */
    List<DeviceWhiteList> getAffectionNumberByDeviceId(Integer deviceId);

    Integer modifyWhiteList(@Param("list") List<DeviceWhiteList> list);

    Integer delDeviceAllWhiteListByDeviceId(@Param("deviceId") Integer deviceId,@Param("type") int type);

    /**
     * 删除所有号码类数据
     * @param deviceId
     * @return
     */
    Integer deletePhoneByDeviceId(@Param("deviceId")Integer deviceId);
}